package ua.kpi.javatraining.university;

import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/**
 * Department is the abstract base class for all administrative parts of university.
 * Provides implementation of basic getters and setters.
 *
 * @author Vasily Yatsenko
 */
public abstract class Department {
    private String name;
    private final Date creationDate;
    private String headmaster;

    protected Department(String name, String headmaster) {
        this.name = name;
        this.headmaster = headmaster;
        creationDate = Calendar.getInstance().getTime();
    }

    public String getHeadmaster() {
        return headmaster;
    }

    public void setHeadmaster(String headmaster) {
        this.headmaster = headmaster;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCreationDate() {
        return DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH).format(creationDate);
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();

        builder.append(getName());
        builder.append(". Headmaster: ");
        builder.append(getHeadmaster());
        builder.append(". Created ");
        builder.append(getCreationDate());
        return builder.toString();
    }
}
